refactor(components): extract answer-thread turn from ClinicalDashboard (maturity X3)#1034
Conversation
…rd (maturity X3) ClinicalDashboard.tsx is the second maintainability-ratchet monolith. It is already heavily decomposed (72 clinical-dashboard/* modules), so this is an incremental ratchet: extract the self-contained answer-thread turn leaf — the `AnswerTurn` type, `maxVisiblePriorTurns`, and the `PriorAnswerTurnSurface` component (the collapsible read-only view of a previous answer turn) — into a new `src/components/clinical-dashboard/answer-thread-turn.tsx`. Verbatim move — the component body is unchanged and the container imports the three symbols exactly as before. ClinicalDashboard.tsx 4,271 -> 4,157 lines; the maintainability budget is ratcheted 4,272 -> 4,157 to lock in the reduction. A new module name (answer-thread-turn) avoids colliding with the unrelated pre-existing prior-answer-turn-surface.tsx. The residual ClinicalDashboard is a tightly-coupled orchestrator core with no large safe leaves left; further extractions are smaller incremental units. Verified: typecheck, lint, the full unit suite (3,047 passing; only the pre-existing container-only pdf-extraction-budget flake fails), knip (no orphaned exports), maintainability budgets, and the targeted "prior turns visible" Chromium spec that renders the moved component — all pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019Jc1ZYHFjXjn6mE6U6riVU
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
📝 WalkthroughWalkthroughThe prior answer-thread turn UI and supporting contract move from ChangesAnswer thread turn extraction
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
- check:maintainability-budgets was red: the reduced-motion helper import (resolveScrollBehavior) grew ClinicalDashboard.tsx 4272->4274 and DocumentViewer.tsx 1733->1734 (import + one prettier-wrapped call). Ratchet the no-growth budgets by the exact +2/+1; no monolith complexity added, and #1034 is separately decomposing ClinicalDashboard downward. - docs/testing.md: document verify:pr-local (before handoff) and npm run ensure (before browser work) in the Verify checklist. - clinical-dashboard-merge-artifacts.test.ts: also assert the non-answer (sm:mb-0) branch carries the scroll-padding-bottom utility. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013f523gDfoBXPYT4H9vXRkE
Summary
Maturity X3, continued — the second ratchet monolith,
ClinicalDashboard.tsx.Unlike
DocumentViewer(#1025), this file is already heavily decomposed (72src/components/clinical-dashboard/*modules), so the large presentational leaves are longgone and the residual is a tightly-coupled orchestrator core. This is therefore an
incremental ratchet: extract the one clean self-contained leaf that remained inline — the
answer-thread turn — into a new module:
src/components/clinical-dashboard/answer-thread-turn.tsx— theAnswerTurntype,maxVisiblePriorTurns, andPriorAnswerTurnSurface(the collapsible read-only view of aprevious answer turn kept on screen after a newer answer arrives).
Verbatim move — the component body is unchanged and the container imports the three symbols
exactly as before.
ClinicalDashboard.tsx4,271 → 4,157 lines; the maintainability budgetis ratcheted 4,272 → 4,157 to lock it in. The new module name (
answer-thread-turn)deliberately avoids colliding with the unrelated pre-existing
prior-answer-turn-surface.tsx.Honest scope note: the residual dashboard is orchestration (state, effects, data fetch,
handlers) with no large safe leaves left, so further extractions are smaller incremental
units. Off the RAG-ranking lane — no
src/lib/rag/**, retrieval, ranking, or eval filestouched.
Verification
npm run typecheck— 0 errorsnpm run lint— 0 warningsnpm run test— 3,047 passing. The only failure is the pre-existing container-onlypdf-extraction-budgetflake (Python OCR stack absent in this VM), which touches nodashboard code.
npm run check:maintainability-budgets— ratcheted to 4,157, passesnpm run check:knip— no dead code / orphaned exports (all three new exports consumed)verify:ui(Chromium) —ui-smoke.spec.ts"answer mode keeps prior turnsvisible for follow-up questions" (which renders the moved
PriorAnswerTurnSurface) passesagainst the installed
chromium-1194binary.UI note: as in #1025, the container's Playwright browser build (1194) mismatches the project's
pinned build (1228), so the full
verify:uierrors at browser launch — a container limitation,not a code issue. The targeted spec was run against the installed Chromium and passes. CI's
Production UI job runs the full gate with the correct binaries.
Risk and rollout
changed (the moved component's
data-*attributes and DOM are identical).Clinical Governance Preflight
Not applicable — per
scripts/pr-policy.mjs, presentation components are clinical-risk onlywhen they touch auth/upload/download/privacy/patient surfaces, which this does not. No
ingestion, answer generation, retrieval/ranking, source-governance, document-access, privacy,
schema, or production behaviour changed; the rendered output is byte-identical.
Notes
docs/maturity-backlog-workorders.md, X3), updatedon-branch.
rag.tsremains the largest open decomposition target (deferred until the RAGlane is confirmed quiet).
🤖 Generated with Claude Code
Generated by Claude Code
Summary by CodeRabbit
Improvements
Documentation